﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Reticulum
{
    public partial class UpdataPWD : Form
    {
        public UpdataPWD()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox2.Text == "" && textBox1.Text == "")
            {
                MessageBox.Show("请先输入修改密码！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (textBox2.Text == "")
            {
                MessageBox.Show("请输入修改后的密码！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                if (textBox2.Text == textBox1.Text)
                {
                    string sql2 = string.Format("update Users set UserPwd={0} where UserAccount={1}", textBox2.Text, ForgetPWD.UserAccount);
                    bool result2 = DBHelps.Command(sql2);
                    if (result2)
                    {
                        MessageBox.Show("您新改的密码是：" + textBox2.Text + "\n请记住此密码哦！", "修改成功！");
                    }
                    else MessageBox.Show("修改失败！");
                }
                else if (textBox2.Text != textBox1.Text)
                {
                    MessageBox.Show("两次输入的密码不一致！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
    }
}
